#ifndef __PACKET_SOURCE_H__
#define __PACKET_SOURCE_H__ 1

namespace NPacketSource
{
	enum EPayloadInfo
	{
		PAYLOAD_ERROR = 0,
		PAYLOAD_EOF, // payload size: 0 to max
		PAYLOAD_NO_DATA, // payload size is 0
		PAYLOAD_DATA, // payload > 0
	};
}

/**
 * @brief packet source implementing a packet-based protocol
 * @author jwurzer, mnutzinger
 */
class IPacketSource
{
public:
	IPacketSource() { }
	virtual ~IPacketSource() { }

	/**
	 * get a packet from the packet source (from upper to lower layer)
	 * @note pPacket and pPacketLength only make sense if return value is true
	 * @note minimum payload length is always 1 (if return value of true)
	 *
	 * @param pPacket pointer to the bytes representing the packet
	 * @param pPacketLength number of bytes
	 * @param pMaxLength maximum number of bytes for the returned packet
	 * @return true on data available, false otherwise
	 */
	virtual NPacketSource::EPayloadInfo getPacket(void*& pPacket, unsigned int& pPacketLength,
			unsigned int pMaxLength) = 0;

	/**
	 * put a packet to the packet source (from lower to upper layer)
	 *
	 * @param pPacket pointer to the bytes representing the packet
	 * @param pPacketLength number of bytes
	 */
	virtual void putPacket(void* pPacket, unsigned int pPacketLength) = 0;
};

#endif // __PACKET_SOURCE_H__

